from datetime import timedelta
from redis import StrictRedis
import logging

# 设置配置信息
class Config(object):
    # 1.debug模式
    DEBUG = True
    SECRET_KEY = "ddsacc"

    #2.数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information15"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 当回话结束时自动提交
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    #3.redis配置
    REDTS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # 4.设置session配置信息
    SESSION_TYPE = "redis"
    SESSION_USE_SIGNER = True
    SESSION_REDIS = StrictRedis(host=REDTS_HOST,port = REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = timedelta(days=2)   #设置两天有效

    LEVEL = logging.DEBUG

# 开发阶段配置
class DevelopConfig(Config):
    pass
# 生产（线上）阶段配置
class ProductConfig(Config):
    DEBUG = False
    LEVEL = logging.ERROR
# 测试阶段配置
class TestConfig(Config):
    TESTING = True

# 提供配置信息的入口
config_dict = {
    "develop":DevelopConfig,
    "product":ProductConfig,
    "test":TestConfig
}